package it.univaq.mwt.model.entity;

import java.io.Serializable;
import java.sql.Blob;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
@Entity 
@NamedQueries({ 
	@NamedQuery(name="getFileByIdGift",query="SELECT f  FROM Files f WHERE f.gift.id=:id_gift")
	
})
@SequenceGenerator(name="sequence",sequenceName="MASTER.FILES_SEQ")
public class Files implements Serializable  {

	@Id
	@GeneratedValue(generator="sequence")    
	@Column(name="id_file",nullable=false,length=11)
	private int idFile;
	
	@Column(name="name",nullable=false,length=200)
	private String name;
	
	@Column(name="path",nullable=false,length=200)
	private String path;
	
	@Column(name="mime",nullable=false,length=20)
	private String mime;
	
	@Lob
	@Column(name="data",nullable=true)
	private byte[] data;
	
	//@OneToOne(mappedBy="files",cascade={CascadeType.MERGE,CascadeType.REMOVE,CascadeType.REFRESH})
	@OneToOne(mappedBy="files")
	private Gift gift;
		
	
	public Gift getGift() { 
		return gift;
	}

	public void setGift(Gift gift) {
		this.gift = gift;
	}

	public int getIdFile() {
		return idFile;
	}

	public void setIdFile(int idFile) {
		this.idFile = idFile;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getMime() {
		return mime;
	}

	public void setMime(String mime) {
		this.mime = mime;
	}

	@Lob
	@Basic(fetch=FetchType.LAZY)
	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}
	
	
}
